<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
	
<%
	request.setAttribute("title","培训详情");
	request.setAttribute("modelConfigPath", "share");
%>

<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
<style type="text/css">
.content{
margin-bottom:28px;
}
</style>
<t:panel cssClass="panel-flat form-detailed" customBody="true" customHead="true">
    <div class="detailed-navbar-content panel-body content">
        <t:form commandName="trainCourse" action="/admin/share/trainCourse/save" method="post" cssClass="form-horizontal">
            <div class="hide">
                <t:hidden path="id"/>
                <t:hidden path="deleteMark"/>
                <t:input type="hidden" path="viewTimes.type" />
                <t:input type="hidden" path="courceThumbnailId" />
                <t:input type="hidden" path="courcePathId" /> 
            </div>
            <t:formgroup>
                <t:label path="courseTitle" cssClass="col-sm-2" />
                <t:input path="courseTitle" colClass="col-sm-10" />
            </t:formgroup>
            <t:formgroup>
                <t:label path="courseType" cssClass="col-sm-2" />
                <t:select2 path="courseType" colClass="col-sm-4" />
                <t:label path="courseKinds" cssClass="col-sm-2" />
                <t:select2 path="courseKinds" colClass="col-sm-4" />
            </t:formgroup>
            <t:formgroup>
                <t:label path="courseTeacher" cssClass="col-sm-2" />
                <t:input path="courseTeacher" colClass="col-sm-4" />
                <label for="courseVideo" class="col-sm-2 control-label cursor-pointer text-right">视频</label> 
                <div class="col-sm-4">
                	<input type="text" id="courseVideo" value="${tfn:getFileName(trainCourse.courcePathId)}" class="form-control custom-input " />
                </div>
            </t:formgroup>
            <t:formgroup>
               <div class="col-sm-6">
                <t:label path="courceThumbnailId" cssClass="col-sm-4" /> 
                    <div class="col-sm-4">      
                	<c:if test="${trainCourse.courceThumbnailId!=null && trainCourse.courceThumbnailId!=''}">
					    <img style="width:100px; height:80px;" id="smallPicShow" src="${tfn:getFileUrl(trainCourse.courceThumbnailId)}" /> 
				    </c:if>
				    <c:if test="${trainCourse.courceThumbnailId ==null || trainCourse.courceThumbnailId==''}">
						<img style="width:100px; height:80px;" id="smallPicShow" src=" <c:url value='/images/we/invitationIndex/bg1.jpg' />" />
				    </c:if>
				    </div>
				     <div class="col-sm-4">
				      <label>加载进度</label>
                       <div style="width:100px;height: 10px;margin-top:0.5rem; border: 2px solid #afafaf;border-radius:15px;"class="picParent">
        			     <div style="width:0px;height: 7px;background-color: #afafaf" class="picProgress"></div>
        		       </div>
				      <button type="button" id="deleteSmallPic"  class="btn-info" style="padding-left:10px;border-radius:6px; margin-top:1rem">删除图片</button> 
                     </div>
                </div>
                <div class="col-sm-offset-9">
                      <label>加载进度</label>
                       <div style="width:100px;height: 10px;margin-top:0.5rem; border: 2px solid #afafaf;border-radius:15px;"class="videoParent">
        			     <div style="width:0px;height: 7px;background-color: #afafaf" class="videoProgress"></div>
        		       </div>
                <button type="button" class="btn-info" style="border-radius:6px; margin-top:1rem" id="deleteVideo" >删除视频</button>
                </div>
            </t:formgroup>
             <t:formgroup>
                <t:label path="courceTrueprice" cssClass="col-sm-2" />
                <t:input path="courceTrueprice" colClass="col-sm-2" />
                <t:select2 path="courceTrueCurrency" colClass="col-sm-2" />
                <t:label path="courceSellingprice" cssClass="col-sm-2" />
                <t:input path="courceSellingprice" colClass="col-sm-2" />
                <t:select2 path="courceSellingCurrency" colClass="col-sm-2" />
            </t:formgroup>
            <t:formgroup>
				<t:label path="courseDescription" cssClass="col-sm-2" />
				<t:ueditor toolbarStyle="default" path="courseDescription" style="height:150px;" colClass="col-sm-10" />
			</t:formgroup>
        </t:form>
    </div>
    <div class="navbar-fixed-bottom">
    <t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
		<t:button icon="icon-floppy-disk" onclick="saveData()"
			cssClass="btn-info" csize="sm">保存</t:button>
	  </t:panelFoot>
	</div>
</t:panel>


<script type="text/javascript">
	function saveData(){
		
		if (loadPic() == false ) {
			return;
		}
		
		if (!$("form:first").valid()){
			return;
		}
		$("form:first").submit();
	}	
	
	$(function(){
		$("#smallPicShow").on('click',function(e) {
			$(".picProgress").width(0);
			$("#courceThumbnailId").startCosFileUpload({
				fillImg:"#smallPicShow",
				progressCallback:function(curr, sha1){
					$(".picParent").show();
					$(".picProgress").width(0);
					$(".picProgress").width(sha1*96);
				}
			});
		});
		
		$("#courseVideo").on('click',function(e) {
			$(".videoProgress").width(0);
			$("#courcePathId").startCosFileUpload({
				fillName:"#courseVideo",
				progressCallback:function(curr, sha1){
					$(".videoParent").show();
					$(".videoProgress").width(0);
					$(".videoProgress").width(sha1*96);
				}
			});
		});
	});	
	
	$(function(){
		$("#deleteSmallPic").on('click',function(e){
			$(".picProgress").width(0);
			$("#smallPicShow").attr("src",$.getVirtualPath()+"/images/we/invitationIndex/bg1.jpg");
			$("#courceThumbnailId").val("");
			console.log(result);
		});
		
		$("#deleteVideo").on('click',function(e){
			$(".videoProgress").width(0);
			$("#courseVideo").attr("value"," ");
			$("#courcePathId").val("");
			console.log(result);
		});
	});
	
	$(function(){

		$("#courceTrueprice").on("change",function(){
	        loadPrice();
		}) 
		
		$("#courceTrueCurrency").on("change",function(){
			loadPrice();
		})  

		$("#courceSellingprice").on("change",function(){
	        loadMaketPrice();
		}) 
		
		$("#courceSellingCurrency").on("change",function(){
			loadMaketPrice();
		})  

	}); 

 	function loadPrice(){
		var courceTrueprice=$("#courceTrueprice").val();
		var courceTrueCurrency=$("#courceTrueCurrency").val();
		
 		if(courceTrueCurrency == "yuan"){
			var reg = /(^((\d{1,9}.\d{1,2})|(\d{1,9}))$)/;
		if(!reg.test(courceTrueprice)){
			var errorConfig = {
	                content:"请输入正整数或1-2位小数",
	                alignTo: 'target',
	                alignX: "left",
	                alignY: 'center',
	                showOn: 'none',
	                bgImageFrameSize: 9,
	                offsetX: 5
	            };
$("#courceTrueprice").poshytip(errorConfig).poshytip("show");
			
					return false;
			} else{
				
	$("#courceTrueprice").poshytip("destroy");
				return true;
	        }
		 }
		
		if(courceTrueCurrency == "jindou"){
			var reg= /(^((\d{1,9}))$)/;
			if(!reg.test(courceTrueprice)){
				var errorConfig = {
		                content:"请输入正整数",
		                alignTo: 'target',
		                alignX: "left",
		                alignY: 'center',
		                showOn: 'none',
		                bgImageFrameSize: 9,
		                offsetX: 5
		            };
	$("#courceTrueprice").poshytip(errorConfig).poshytip("show");
					return false;
				}
			else{
	   $("#courceTrueprice").poshytip("destroy");
	                return true;
		 		}
			} 
	}; 
	
	function loadMaketPrice(){
		var courceSellingprice=$("#courceSellingprice").val();
		var courceSellingCurrency=$("#courceSellingCurrency").val();
		if(courceSellingCurrency == "yuan"){
			var reg = /(^((\d{1,9}.\d{1,2})|(\d{1,9}))$)/;
		if(!reg.test(courceSellingprice)){
			var errorConfig = {
	                content:"请输入正整数或1-2位小数",
	                alignTo: 'target',
	                alignX: "left",
	                alignY: 'center',
	                showOn: 'none',
	                bgImageFrameSize: 9,
	                offsetX: 5
	            };
$("#courceSellingprice").poshytip(errorConfig).poshytip("show");
			
					return false;
			} else{
				
	$("#courceSellingprice").poshytip("destroy");
				return true;
	        }
		 }
		
		if(courceSellingCurrency == "jindou"){
			var reg= /(^((\d{1,9}))$)/;
			if(!reg.test(goodsMaketPrice)){
				var errorConfig = {
		                content:"请输入正整数",
		                alignTo: 'target',
		                alignX: "left",
		                alignY: 'center',
		                showOn: 'none',
		                bgImageFrameSize: 1,
		                offsetX: 5
		            };
	$("#courceSellingprice").poshytip(errorConfig).poshytip("show");
					return false;
				}
			else{
	   $("#courceSellingprice").poshytip("destroy");
	                return true;
		 		}
			}
	}

function loadPic(){
	var picId=$("#courceThumbnailId").val();
	if(picId==null || picId==""){
		var errorConfig = {
                content:"请上传图片",
                alignTo: 'target',
                alignX: "left",
                alignY: 'center',
                showOn: 'none',
                bgImageFrameSize: 1,
                offsetX: 5
            };
$("#smallPicShow").poshytip(errorConfig).poshytip("show");
			return false;
	}else{
		$("#smallPicShow").poshytip("destroy");
        return true;
	}
}
	

</script>
<%@ include file="/WEB-INF/views/shared/base/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formpickers.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/editor/ueditor.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/tools/upload-cos.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>